﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp.Common.Http
{
    public class Fax
    {
        public static bool SendFax(FaxInformation faxInfo)
        {
            if (faxInfo.FaxNumber != "")
            {
                try
                {
                    FAXCOMLib.FaxServer faxServer = new FAXCOMLib.FaxServer();

                    faxServer.Connect(faxInfo.FaxServerName);
                    FAXCOMLib.FaxDoc faxDoc = (FAXCOMLib.FaxDoc)faxServer.CreateDocument(faxInfo.FileName);
                    faxDoc.RecipientName = faxInfo.RecipientName;
                    faxDoc.FaxNumber = faxInfo.FaxNumber;
                    faxDoc.DisplayName = faxInfo.DocumentName;
                    int Response = faxDoc.Send();
                    faxServer.Disconnect();

                    return true;
                }
                catch (Exception Ex)
                {
                    return false;
                }
            }
            else
            {
                return false;
            }

        }
    }
}
